#line 1 "/Users/wangxiaojin/Desktop/Test/TestDylib/Logos/TestDylib.xm"


#import <CoreLocation/CoreLocation.h>
#import <UIKit/UIKit.h>
#import "WBAssistantManager.h"
#import "WBWifiStore.h"
#import "WBWifiModel.h"
#import <SystemConfiguration/CaptiveNetwork.h>


#include <substrate.h>
#if defined(__clang__)
#if __has_feature(objc_arc)
#define _LOGOS_SELF_TYPE_NORMAL __unsafe_unretained
#define _LOGOS_SELF_TYPE_INIT __attribute__((ns_consumed))
#define _LOGOS_SELF_CONST const
#define _LOGOS_RETURN_RETAINED __attribute__((ns_returns_retained))
#else
#define _LOGOS_SELF_TYPE_NORMAL
#define _LOGOS_SELF_TYPE_INIT
#define _LOGOS_SELF_CONST
#define _LOGOS_RETURN_RETAINED
#endif
#else
#define _LOGOS_SELF_TYPE_NORMAL
#define _LOGOS_SELF_TYPE_INIT
#define _LOGOS_SELF_CONST
#define _LOGOS_RETURN_RETAINED
#endif

@class DTAppDelegate; @class DTInfoPlist; @class AMapLocationManager; 
static void (*_logos_orig$_ungrouped$DTAppDelegate$applicationDidBecomeActive$)(_LOGOS_SELF_TYPE_NORMAL DTAppDelegate* _LOGOS_SELF_CONST, SEL, id); static void _logos_method$_ungrouped$DTAppDelegate$applicationDidBecomeActive$(_LOGOS_SELF_TYPE_NORMAL DTAppDelegate* _LOGOS_SELF_CONST, SEL, id); static void (*_logos_orig$_ungrouped$AMapLocationManager$locationManager$didUpdateLocations$)(_LOGOS_SELF_TYPE_NORMAL AMapLocationManager* _LOGOS_SELF_CONST, SEL, id, id); static void _logos_method$_ungrouped$AMapLocationManager$locationManager$didUpdateLocations$(_LOGOS_SELF_TYPE_NORMAL AMapLocationManager* _LOGOS_SELF_CONST, SEL, id, id); static NSString * (*_logos_meta_orig$_ungrouped$DTInfoPlist$getAppBundleId)(_LOGOS_SELF_TYPE_NORMAL Class _LOGOS_SELF_CONST, SEL); static NSString * _logos_meta_method$_ungrouped$DTInfoPlist$getAppBundleId(_LOGOS_SELF_TYPE_NORMAL Class _LOGOS_SELF_CONST, SEL); 

#line 10 "/Users/wangxiaojin/Desktop/Test/TestDylib/Logos/TestDylib.xm"


static void _logos_method$_ungrouped$DTAppDelegate$applicationDidBecomeActive$(_LOGOS_SELF_TYPE_NORMAL DTAppDelegate* _LOGOS_SELF_CONST __unused self, SEL __unused _cmd, id arg1) {
_logos_orig$_ungrouped$DTAppDelegate$applicationDidBecomeActive$(self, _cmd, arg1);
    [[WBAssistantManager sharedManager] showMenu];
    [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
}



CFArrayRef (*oldCNCopySupportedInterfaces)();
CFDictionaryRef (*oldCNCopyCurrentNetworkInfo)(CFStringRef interfaceName);
Boolean (*oldSCNetworkReachabilityGetFlags)(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags *flags);

CFArrayRef newCNCopySupportedInterfaces() {
    CFArrayRef result = NULL;

    WBWifiModel *wifi = [[WBWifiStore sharedStore] wifiHooked];

    if(wifi && wifi.interfaceName) {
        NSArray *array = [NSArray arrayWithObject:wifi.interfaceName];
        result = (CFArrayRef)CFRetain((__bridge CFArrayRef)(array));
    }

    if(!result) {
        result = oldCNCopySupportedInterfaces();
    }

    return result;
}

CFDictionaryRef newCNCopyCurrentNetworkInfo(CFStringRef interfaceName) {
    CFDictionaryRef result = NULL;

    WBWifiModel *wifi = [[WBWifiStore sharedStore] wifiHooked];
    if(wifi) {
        NSDictionary *dictionary = @{
            @"BSSID": (wifi.BSSID ? wifi.BSSID : @""),
            @"SSID": (wifi.SSID ? wifi.SSID : @""),
            @"SSIDDATA": (wifi.SSIDData ? wifi.SSIDData : @"")
        };
        result = (CFDictionaryRef)CFRetain((__bridge CFDictionaryRef)(dictionary));
    }

    if(!result) {
        result = oldCNCopyCurrentNetworkInfo(interfaceName);
    }

    return result;
}

Boolean newSCNetworkReachabilityGetFlags(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags *flags) {
    Boolean result = false;

    WBWifiModel *wifi = [[WBWifiStore sharedStore] wifiHooked];
    if(wifi && wifi.flags > 0) {
        result = true;
        *flags = wifi.flags;
    }

    if(!result) {
        result = oldSCNetworkReachabilityGetFlags(target, flags);
    }
    return result;
}

static __attribute__((constructor)) void _logosLocalCtor_72aaf43c(int __unused argc, char __unused **argv, char __unused **envp) {
        {Class _logos_class$_ungrouped$DTAppDelegate = objc_getClass("DTAppDelegate"); MSHookMessageEx(_logos_class$_ungrouped$DTAppDelegate, @selector(applicationDidBecomeActive:), (IMP)&_logos_method$_ungrouped$DTAppDelegate$applicationDidBecomeActive$, (IMP*)&_logos_orig$_ungrouped$DTAppDelegate$applicationDidBecomeActive$);Class _logos_class$_ungrouped$AMapLocationManager = objc_getClass("AMapLocationManager"); MSHookMessageEx(_logos_class$_ungrouped$AMapLocationManager, @selector(locationManager:didUpdateLocations:), (IMP)&_logos_method$_ungrouped$AMapLocationManager$locationManager$didUpdateLocations$, (IMP*)&_logos_orig$_ungrouped$AMapLocationManager$locationManager$didUpdateLocations$);Class _logos_class$_ungrouped$DTInfoPlist = objc_getClass("DTInfoPlist"); Class _logos_metaclass$_ungrouped$DTInfoPlist = object_getClass(_logos_class$_ungrouped$DTInfoPlist); MSHookMessageEx(_logos_metaclass$_ungrouped$DTInfoPlist, @selector(getAppBundleId), (IMP)&_logos_meta_method$_ungrouped$DTInfoPlist$getAppBundleId, (IMP*)&_logos_meta_orig$_ungrouped$DTInfoPlist$getAppBundleId);}
        MSHookFunction(&CNCopySupportedInterfaces, &newCNCopySupportedInterfaces, &oldCNCopySupportedInterfaces);
        MSHookFunction(&CNCopyCurrentNetworkInfo, &newCNCopyCurrentNetworkInfo, &oldCNCopyCurrentNetworkInfo);
        MSHookFunction(&SCNetworkReachabilityGetFlags, &newSCNetworkReachabilityGetFlags, &oldSCNetworkReachabilityGetFlags);
}



static void _logos_method$_ungrouped$AMapLocationManager$locationManager$didUpdateLocations$(_LOGOS_SELF_TYPE_NORMAL AMapLocationManager* _LOGOS_SELF_CONST __unused self, SEL __unused _cmd, id arg1, id arg2){

    double latitude = [[[NSUserDefaults standardUserDefaults] objectForKey:@"latitude"] doubleValue];
    double longitude = [[[NSUserDefaults standardUserDefaults] objectForKey:@"longitude"] doubleValue];
    NSLog(@"%f %f",latitude, longitude);

    CLLocation *lar = [[CLLocation alloc] initWithLatitude:latitude longitude:longitude];
    NSMutableArray *array = (NSMutableArray *)arg2;
    [array removeAllObjects];
    [array addObject:lar];
    _logos_orig$_ungrouped$AMapLocationManager$locationManager$didUpdateLocations$(self, _cmd, arg1, array);
}





static NSString * _logos_meta_method$_ungrouped$DTInfoPlist$getAppBundleId(_LOGOS_SELF_TYPE_NORMAL Class _LOGOS_SELF_CONST __unused self, SEL __unused _cmd){
    return @"com.laiwang.DingTalk";
}


